'use strict';

angular.module('hackathonApp', [
  'ngResource',
  'ngRoute',
  'ngGrid',
  'ngAnimate'
])
  .config(function ($routeProvider) {
    $routeProvider
    .when('/', {
      templateUrl: 'views/dashboard.html',
      controller: 'DashboardCtrl'
    })
    .when('/issues', {
        templateUrl: 'views/issues/list.html',
        controller: 'IssuesListCtrl'
    })
    .when('/issues/:id/edit', {
        templateUrl: 'views/issues/form.html',
        controller: 'IssuesFormCtrl'
    })
    .when('/issues/new', {
        templateUrl: 'views/issues/form.html',
        controller: 'IssuesFormCtrl'
    })
    .when('/duns/:name/:state', {
      templateUrl: 'views/duns.html',
      controller: 'DunsCtrl'
    })
    .when('/duns/:name', {
      templateUrl: 'views/duns.html',
      controller: 'DunsCtrl'
    })
    .when('/duns', {
      templateUrl: 'views/duns.html',
      controller: 'DunsCtrl'
    })
    .when('/zip', {
      templateUrl: 'views/zip.html',
      controller: 'ZipCtrl'
    })
    .when('/providers', {
      templateUrl: 'views/providers.html',
      controller: 'ProvidersCtrl'
    })
    .when('/providers/:id', {
      templateUrl: 'views/providers_form.html',
      controller: 'ProvidersFormCtrl'
    })
    .when('/test', {
      templateUrl: 'views/test.html',
      controller: 'TestCtrl'
    })
    .otherwise({
      redirectTo: '/'
    });
  }).run(function($rootScope) {

	  /**
	   *  @namespace The DNB Javascript Library.
	   */
	  
	  $rootScope.DNB = window.DNB || {};
	  if ($rootScope.DNB.Api === undefined) throw 'Error:  DNB API Library missing';
  		
  });
